package service.impl;

import commons.ibatis.BaseDao;
import dao.Dao;
import entity.Dept;
import entity.Emp;
import entity.EmpVo;
import entity.Login;
import service.Service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ServiceImpl implements Service {
    /**
     * @param account
     * @return
     */
    @Override
    public EmpVo queryEmpByAccoubt(String account) {
        EmpVo empVo = null;
        try {
            empVo = BaseDao.getSession().getMapper(Dao.class).selectEmpByAccount(account);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return empVo;
    }

    /**
     * @return
     */
    @Override
    public List<Dept> queryAllDept(int did) {
        List<Dept> depts = new ArrayList<Dept>();
        try {
            depts = BaseDao.getSession().getMapper(Dao.class).selectAllDept(did);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return depts;
    }

    /**
     * @param did
     * @return
     */
    @Override
    public List<EmpVo> selelctEmpByDept(int did, int from, int eid) {
        List<EmpVo> empVos = new ArrayList<EmpVo>();
        try {
            empVos = BaseDao.getSession().getMapper(Dao.class).selelctEmpByDept(did, from, eid);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return empVos;
    }

    /**
     * @param did
     * @return
     */
    @Override
    public int selelctEmpCountByDept(int did) {
        int i = 0;
        try {
            i = BaseDao.getSession().getMapper(Dao.class).selectEmpCountByDept(did);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }
}
